package com.pureut.order.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.pureut.order.dto.ProcurementPlanDetailDto;
import com.pureut.order.dto.ProcurementPlanDetailViewDto;
import com.pureut.order.service.ProcurementPlanDetailService;
import com.pureut.order.vo.PlanReleaseVo;
import com.pureut.order.vo.ProcurementPlanDetailVo;
import com.sale.common.core.domain.R;
import com.sale.common.core.web.controller.BaseController;
import com.sale.common.log.annotation.Log;
import com.sale.common.log.enums.BusinessType;
import com.sale.common.mybatis.core.page.PageQuery;
import com.sale.common.mybatis.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 采购明细控制层
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/procurement-plan-detail")
public class ProcurementPlanDetailController extends BaseController {

   private final ProcurementPlanDetailService procurementPlanDetailService;

    /**
     * 采购明细分页列表
     */
    //@SaCheckPermission("order:purchase:plan:detaillist")
    @GetMapping("/list")
    public TableDataInfo<ProcurementPlanDetailDto> list(ProcurementPlanDetailVo procurementPlanDetailVo, PageQuery pageQuery) {
        //查询采购明细列表
        return procurementPlanDetailService.getList(procurementPlanDetailVo, pageQuery);

    }

    /**
     * 计划下达数据回显
     */
    @GetMapping("/planReleaseView/{ids}")
    public R<List<ProcurementPlanDetailViewDto>> planReleaseView(@PathVariable("ids") String ids) {
        return R.ok(procurementPlanDetailService.planReleaseView(ids));
    }


    /**
     * 计划下达
     */
    //@SaCheckPermission("order:purchase:plan:planRelease")
    @Log(title = "计划下达", businessType = BusinessType.INSERT)
    @PostMapping("/planRelease")
    public R<Void> planRelease(@RequestBody PlanReleaseVo planReleaseVo) throws Exception {
        return toAjax(procurementPlanDetailService.planRelease(planReleaseVo));
    }
}
